// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import ElementUI, { Message,Pagination,MessageBox  } from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import router from './router'
import axios from 'axios'
import '../src/assets/css/global.css'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import Timeline from './plugins/timeline/index.js'
import TimelineItem from './plugins/timeline/index.js'
Vue.use(Timeline)
Vue.use(TimelineItem)
// 富文本编辑器
Vue.use(VueQuillEditor)

Vue.use(Pagination)
// 消息弹框挂载到vue原型
Vue.prototype.$message=Message
// 弹框
Vue.prototype.$confirm=MessageBox.confirm
// axios请求
Vue.prototype.$http=axios
axios.defaults.baseURL='http://127.0.0.1:8888/api/private/v1/'

Vue.component('TreeTable',TreeTable)

// 格式化时间过滤器
Vue.filter('dateFormat',(shijianchuo)=>{
  const dt = new Date(shijianchuo)
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2,'0');
  const d = (dt.getDate() + '').padStart(2,'0');
  const h = (dt.getHours() + '').padStart(2,'0');
  const mm = (dt.getMinutes() + '').padStart(2,'0');
  const s = (dt.getSeconds() + '').padStart(2,'0');
  return `${y}-${m}-${d}-${h}-${mm}-${s}`;
})

// 请求拦截器
// 在request拦截器中展示进度条NProgress.start();
axios.interceptors.request.use(config =>{
  // 展示进度条
  NProgress.start();
  // 为请求头对象添加Token认证的Authorization字段
  config.headers.Authorization = window.sessionStorage.getItem('token')
  // 在最后必须returnconfig
  return config;
})
// 在response拦截器中隐藏进度条NProgress.done();
axios.interceptors.response.use(config =>{
  // 隐藏进度条
  NProgress.done();
  return config;
})
Vue.config.productionTip = false
Vue.use(ElementUI);
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  render: h => h(App)
})
